package dao;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

public class FileIO {
	public static List<String> readFile(String filename) {
		List<String> list = new LinkedList<String>();
		try {
			BufferedReader br = new BufferedReader(new FileReader(filename));

			while (br.ready()) {
				String line = br.readLine();
				list.add(line);
			}
			br.close();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		return list;
	}

	public static void writeFile(String filename, List<String> list) {
		try {
			BufferedWriter bw = new BufferedWriter(new FileWriter(filename));

			for (String line : list) {
				bw.write(line);
			}
			bw.close();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
}
